package servlet.cuota;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import condominio.excepcion.DAOExcepcion;
import condominio.modelo.Cuota;
import condominio.modelo.Usuario;
import condominio.negocio.GestionCuotas;

/**
 * Servlet implementation class for Servlet: RolBuscarServlet
 * 
 */
@WebServlet("/CuotaBuscarServlet")
public class CuotaBuscarServlet extends javax.servlet.http.HttpServlet implements
		javax.servlet.Servlet {
	static final long serialVersionUID = 1L;

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public CuotaBuscarServlet() {
		super();
	}

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
	 * HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		Usuario vo = (Usuario)session.getAttribute("USUARIO_ACTUAL");
		
		if (vo ==null){
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
			return;
		}
		
		
		
		this.doPost(request, response);
	}

	
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		
		//System.out.println("Dentro de doPost del servlet RolBuscarSerlvet");
//		Integer x = Integer.parseInt(request.getParameter("idCuota"));
//		GestionCuotas negocio = new GestionCuotas();
//		try {
//			Collection<Cuota> lista = negocio.buscarporcuotas(x);
//			// Guardar en el ambiente de request
//			request.setAttribute("cuotas", lista);
//			RequestDispatcher rd = request.getRequestDispatcher("CuotasBuscar.jsp");
//			rd.forward(request, response);
//
//		} catch (Exception e) {
//			System.out.println(e.getMessage());
//			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
//			rd.forward(request, response);
//		}

	}
}
